/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package convert;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.inject.Named;
import model.entity.Depot;
import service.InterfaceServiceLocal;

/**
 * 求解状态
 *
 * @author dingnangen
 */
@Named("operationStateConvert")
@RequestScoped
public class OperationStateConvert implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {

        int s = -1;
        switch (value) {
            case "未选定方案":
                s = -1;
                break;
            case "未开始":
                s = 0;
                break;
            case "进行中":
                s = 1;
                break;
            case "已完成":
                s = 2;
                break;
            default:
                break;
        }

        return s;

    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        String s = "未知";
        switch ((int) value) {
            case -1:
                s = "未选定方案";
                break;
            case 0:
                s = "未开始";
                break;
            case 1:
                s = "进行中";
                break;
            case 2:
                s = "已完成";
                break;
            default:
                break;
        }

        return s;

    }

}
